package TestTime;


import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.sql.Timestamp;
import java.util.TimeZone;

public class TestTimeMain {
	public static void main(String[] args) {
//


		Timestamp ti = new Timestamp(System.currentTimeMillis());
		String timeS = ti.toString();
		System.out.println(timeS);
		String s = timeS.substring(0, timeS.length() - 4);
		System.out.println(s.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""));

		DateTime d1 = new DateTime(System.currentTimeMillis());


		DateTime dt = d1.minusWeeks(1);
		dt = dt.dayOfWeek().withMinimumValue();
		System.out.println(dt);

		DateTime d2 = d1.minusWeeks(1);
		d2 = d2.dayOfWeek().withMaximumValue();
		System.out.println(d2);


		Timestamp timestamp = new Timestamp(1417449600000l);
		System.out.println(timestamp);


		Timestamp timestamp1 = new Timestamp(1417535999999l);
		System.out.println(timestamp1);
		DateTimeZone.setDefault(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+8")));
//		String time = "2014-12";
		DateTime dateTime = DateTime.now();
		DateTime.Property property = dateTime.dayOfMonth();
		System.out.println(property.getMaximumValue());

		String time = "2014-12";
		DateTime dateTime1 = DateTime.parse(time);

		dateTime1.getDayOfMonth();
		System.out.println(dateTime1);
		System.out.println(dateTime1.dayOfMonth().getMaximumValue());
//		try {
//			dateTime = DateTime.parse(time);
//		} catch (Exception e) {
//			DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd hh:mm");
//			try {
//				dateTime = DateTime.parse(time, fmt);
//			} catch (Exception e1) {
//				fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
//				dateTime = DateTime.parse(time, fmt);
//			}
//		}

	}
}
